﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using HigLabo.Net.Extensions;
using Newtonsoft.Json.Linq;

namespace HigLabo.Net.Twitter
{
    /// <summary>
    /// 
    /// </summary>
    public class Friends : ResponseObject
    {
        private Int64 _PreviousCursor = 0;
        private String _PreviousCursorStr = "";
        private Int64 _NextCursor = 0;
        private String _NextCursorStr = "";
        private List<Int64> _IDs = new List<Int64>();
        /// <summary>
        /// 
        /// </summary>
        public Int64 PreviousCursor
        {
            get { return _PreviousCursor; }
            set { _PreviousCursor = value; }
        }
        /// <summary>
        /// 
        /// </summary>
        public String PreviousCursorStr
        {
            get { return _PreviousCursorStr; }
            set { _PreviousCursorStr = value; }
        }
        /// <summary>
        /// 
        /// </summary>
        public Int64 NextCursor
        {
            get { return _NextCursor; }
            set { _NextCursor = value; }
        }
        /// <summary>
        /// 
        /// </summary>
        public String NextCursorStr
        {
            get { return _NextCursorStr; }
            set { _NextCursorStr = value; }
        }
        /// <summary>
        /// 
        /// </summary>
        public ICollection<Int64> IDs
        {
            get { return _IDs; }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="jsonText"></param>
        public Friends(String jsonText)
        {
            this.SetProperty(jsonText);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="jsonText"></param>
        public override void SetProperty(string jsonText)
        {
            var d = this.SetData(jsonText);

            object objOut = null;
            this.PreviousCursor = d.ToInt64("previous_cursor") ?? this.PreviousCursor;
            this.PreviousCursorStr = d.ToString("previous_cursor_str");
            this.NextCursor = d.ToInt64("next_cursor") ?? this.NextCursor;
            this.NextCursorStr = d.ToString("next_cursor_str");
            d.TryGetValue("ids", out objOut);
            JContainer val = (JContainer)objOut;
            for (int i = 0; i < val.Count(); i++)
            {
                _IDs.Add(Convert.ToInt64(val.ElementAt(i).ToString()));
            }
        }
    }
}
